var timeps = require('../../util/timestamp.js');
Page({
  data: {
	end:4,
	countDownDay: 0,
	countDownHour: 0,
	countDownMinute: 0,
	countDownSecond: 0,
  },
  onLoad: function(options) {
	console.log('金额'+options.pice)
	console.log('到期时间'+options.time)
	console.log('全部'+options.orderInfos)
	this.setData({ //通过setData来修改
		orderInfop: options.orderInfos,
		price:options.pice
	})
	
	
	 var totalSecond = options.time - Date.parse(new Date())/1000;
	  
	  var interval = setInterval(function () {
	   // 秒数
	   var second = totalSecond;
	  
	   // 天数位
	   var day = Math.floor(second / 3600 / 24);
	   var dayStr = day.toString();
	   if (dayStr.length == 1) dayStr = '0' + dayStr;
	  
	   // 小时位
	   var hr = Math.floor((second - day * 3600 * 24) / 3600);
	   var hrStr = hr.toString();
	   if (hrStr.length == 1) hrStr = '0' + hrStr;
	  
	   // 分钟位
	   var min = Math.floor((second - day * 3600 *24 - hr * 3600) / 60);
	   var minStr = min.toString();
	   if (minStr.length == 1) minStr = '0' + minStr;
	  
	   // 秒位
	   var sec = second - day * 3600 * 24 - hr * 3600 - min*60;
	   var secStr = sec.toString();
	   if (secStr.length == 1) secStr = '0' + secStr;
	  
	   this.setData({
	    countDownDay: dayStr,
	    countDownHour: hrStr,
	    countDownMinute: minStr,
	    countDownSecond: secStr,
	   });
	   totalSecond--;
	   if (totalSecond < 0) {
	    clearInterval(interval);
	
		console.log('订单一结束')
	    
	    this.setData({
	     countDownDay: '00',
	     countDownHour: '00',
	     countDownMinute: '00',
	     countDownSecond: '00',
	    });
	   }
	  }.bind(this), 1000);
	
	
  },
  //支付宝
  coocks:function(e){
	   console.log('默认支付宝'+e.currentTarget.dataset.index)
  	  this.setData({ //通过setData来修改
  	  	end: 4,
  	  })
  },
  //微信
  coock:function(e){
	  console.log('默认微信'+e.currentTarget.dataset.index)
	  this.setData({ //通过setData来修改
	  	end: 3,
	  })
  },
 

  
  
  requestPayment:function(){
	  console.log('时间')
	  console.log('典范'+this.data.orderInfop,this.data.end)
	  tt.pay({
	    orderInfo: this.data.orderInfop,
	    service: 4,
		_debug:1,
	    getOrderStatus(res) {
	        let { out_order_no } = res;
	        return new Promise(function (resolve, reject) {
	  		
	  		 tt.switchTab({ url: '/pages/personal/personal' })
	        });
	      },
	    success(res) {
			console.log('啥意思')
	  	// var postData = {
	  	// 		out_order_no:data.data.out_order_no
	  	// 	}
	  	// 	tt.request({
	  	// 	  url: "https://dy.nbhysj.com/api/getOrderStatus",
	  	// 	  data: postData,
	  	// 	  method: 'POST',
	  	// 	  success(res) {
	  	// 		  console.log('查询到了吗')
	  	// 		  console.log('商户状态'+JSON.stringify(res.data.data.order_status))
	  	// 		 // 商户后端查询的微信支付状态，通知收银台支付结果
	  	// 		 if(res.data.data.order_status==2){
	  	// 			 tt.navigateTo({
	  	// 			 	url: '/pages/verification/verification?order_no='+res.data.data.id
	  	// 			 })
	  	// 		 }
	  	// 	  },
	  	// 	  fail(err) {
	  	// 		reject(err);
	  	// 	  }
	  	// 	});
	  		
	  	
	  
	    },
	     fail(res) {
	      
	      },
	  });
  }
  //跳转景区信息
  // confirm: function () {
  // 	  console.log('事件')
  //   tt.navigateTo({ url: '/pages/verification/verification' })
  // }, 
	
});